import sys
import os
sys.path.append(os.path.abspath(os.path.dirname(__file__)) + "/..")
from stock.simulatestock import *
from utils.smtp.smtp import *
from utils.utils import *
import time




def em_proc(code, sa):
    kday = SimulateStock(code, 240*7, 100)
    if kday.GetData() == False:
        return False

    df_em = get_ema_data(kday.data, 10, 60)

    if len(df_em) < 2:
        print("error len")
        return
    #金叉
    ss = "ema_10"
    ls = "ema_60"
    # print(df_em)
    # print(df_em[ss])
    # print(df_em[ls])
    if df_em[ss][-2] < df_em[ls][-2] and df_em[ss][-1] > df_em[ls][-1]:
        sa.append(code)
        print(code)

def do_em_proc():
    select_array = []
    codes = get_codes()
    # codes = ["sz300296"]
    for code in codes:
        em_proc(code, select_array)

if __name__ == "__main__":
    do_em_proc()